import request from '@/utils/request'

// 查询成绩详情列表
export function listGrade(query) {
  return request({
    url: '/grade/grade/list',
    method: 'get',
    params: query
  })
}

// 查询成绩详情详细
export function getGrade(gradeId) {
  return request({
    url: '/grade/grade/' + gradeId,
    method: 'get'
  })
}

// 新增成绩详情
export function addGrade(data) {
  return request({
    url: '/grade/grade',
    method: 'post',
    data: data
  })
}

// 修改成绩详情
export function updateGrade(data) {
  return request({
    url: '/grade/grade',
    method: 'put',
    data: data
  })
}

// 删除成绩详情
export function delGrade(gradeId) {
  return request({
    url: '/grade/grade/' + gradeId,
    method: 'delete'
  })
}


export function getGradeDistribution() {
  return request({
    url: '/grade/grade/distribution',
    method: 'get',
    transformResponse: [
      data => {
        try {
          return JSON.parse(data); // 直接返回解析后的数据
        } catch {
          return data; // 非JSON格式则原样返回
        }
      }
    ]
  })
}
